package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.base.util.JwtUtils;
import com.atguigu.srb.core.pojo.entity.UserInfo;
import com.atguigu.srb.core.pojo.entity.UserLoginRecord;
import com.atguigu.srb.core.pojo.query.UserInfoQuery;
import com.atguigu.srb.core.pojo.vo.LoginVO;
import com.atguigu.srb.core.pojo.vo.RegisterVO;
import com.atguigu.srb.core.pojo.vo.UserInfoVO;
import com.atguigu.srb.core.service.UserInfoService;
import com.atguigu.srb.core.service.UserLoginRecordService;
import com.atguigu.srb.result.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户基本信息 前端控制器
 * </p>
 *
 * @author fun
 * @since 2021-10-29
 */
@Api(tags = "admin会员接口")
@RestController
@RequestMapping("/admin/core/userInfo")
public class AdminUserInfoController {
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private UserLoginRecordService userLoginRecordService;

    @ApiOperation("会员列表")
    @GetMapping("/list/{page}/{limit}")
    public R list(@PathVariable("page") Long page, @PathVariable("limit") Long limit, UserInfoQuery userInfoQuery) {
        Page pageParam = new Page<UserInfo>(page,limit);
        Page<UserInfo> userInfoPage = userInfoService.listPage(pageParam, userInfoQuery);
        return R.ok().data("pageModel",userInfoPage);
    }

    @ApiOperation("锁定/解锁")
    @PutMapping("/lock/{id}/{status}")
    public R lock(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        userInfoService.lock(id,status);
        return R.ok();
    }
}

